using UnityEngine;

namespace CinemaDirector
{
	[CutsceneItem("GG-Action", "Scale")]
	public class ScaleAction : CinemaActorAction
	{
		public GGVScale start;

		public GGVScale end;

		public bool useEase;

		public AnimationCurve easeCurve;

		protected Transform actorTransform;

		public override void Initialize()
		{
			base.Initialize();
			start.Init(base.Cutscene.variables);
			end.Init(base.Cutscene.variables);
		}

		public override void Trigger(GameObject actor)
		{
			if (!(actor == null))
			{
				actorTransform = actor.transform;
				start.value.SetCurrent(actorTransform);
				end.value.SetCurrent(actorTransform);
				SetTime(0f);
			}
		}

		public override void End(GameObject actor)
		{
			if (!(actor == null))
			{
				actorTransform = actor.transform;
				start.value.SetCurrent(actorTransform);
				end.value.SetCurrent(actorTransform);
				SetTime(1f);
			}
		}

		public override void UpdateTime(GameObject Actor, float time, float deltaTime)
		{
			if (!(duration <= 0f) && !(actorTransform == null))
			{
				float time2 = time / duration;
				SetTime(time2);
			}
		}

		private void SetTime(float normTime)
		{
			if (useEase)
			{
				normTime = easeCurve.Evaluate(normTime);
			}
			Vector3 localScale = start.value.GetLocalScale(actorTransform);
			Vector3 localScale2 = end.value.GetLocalScale(actorTransform);
			actorTransform.localScale = Vector3Ex.LerpNotClamped(localScale, localScale2, normTime);
		}
	}
}
